package order.service.impl;

import lombok.extern.slf4j.Slf4j;
import order.dao.persist.repository.IOrderRepository;
import order.pojo.authentication.CurrentPrincipal;
import order.pojo.entity.Order;
import order.pojo.param.OrderAddNewParam;
import order.service.IOrderService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

@Service
@Slf4j
public class OrderServiceImpl implements IOrderService {
    @Autowired
    private IOrderRepository orderRepository;

    @Override
    public Long create(CurrentPrincipal currentPrincipal, OrderAddNewParam orderAddNewParam) {
        log.debug("开始处理【创建订单】的业务，当事人：{}，参数：{}", currentPrincipal, orderAddNewParam);
        return null;
    }

    @Override
    public void orderAdd(OrderAddNewParam orderAddNewParam) {
        Order order = new Order();
        BeanUtils.copyProperties(orderAddNewParam, order);
        order.setOrderNum("3");
        int rows = orderRepository.insert(order);

        if (rows != 1) {
            String message = "发布商品失败，服务器忙，请稍后再尝试！";
            log.warn(message);
        }
    }
}
